<?php

/**
 * @author Lam Vu Nhat
 * @copyright 2011
 */
class Muare_Cache_ControllerPublic_Index extends XFCP_Muare_Cache_ControllerPublic_Index
{
	public function actionIndex()
	{
		$this->canonicalizeRequestUrl(XenForo_Link::buildPublicLink('index'));

		// New cache core obj
		$cache = new Muare_Cache_Core();
		if (($nodeList = $cache->load('nodeList')) === false)
		{// Load cache node list
			$nodeList = $this->_getNodeModel()->getNodeDataForListDisplay(false, 0);
		}

		if (XenForo_Application::get('options')->MRCacheNodeList)
		{// Save cache node list
			$cache->save($nodeList, XenForo_Application::get('options')->MRCacheNodeList);
		}

		if (($onlineUsers = $cache->load('onlineUsers')) === false)
		{// Load cache online user
			$onlineUsers = $this->_getSessionActivityList();
		}

		if (XenForo_Application::get('options')->MRCacheOnlineUsers)
		{// Save cache online user
			$cache->save($onlineUsers, XenForo_Application::get('options')->MRCacheOnlineUsers);
		}

		$viewParams = array(
			'nodeList' => $nodeList,
            'onlineUsers' => $onlineUsers,
            'boardTotals' => $this->_getBoardTotals()
		);

		return $this->responseView('XenForo_ViewPublic_Forum_List', 'forum_list', $viewParams);
	}
}
